﻿using Architecture.API.Application.TraceabilityCommand.AdditiveCommand;
using MediatR;
using Traceability.Domain.Service.AdditiveServices;

namespace Architecture.API.Application.TraceabilityCommandHandler.AdditiveCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class DeletedAdditiveCommandHandler : IRequestHandler<DeletedAdditiveCommand, int>
    {
        /// <summary>
        /// 添加剂服务
        /// </summary>
        protected readonly IAdditiveService additiveServices;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="additiveServices">添加剂</param>
        public DeletedAdditiveCommandHandler(IAdditiveService additiveServices)
        {
            this.additiveServices = additiveServices;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(DeletedAdditiveCommand request, CancellationToken cancellationToken)
        {
            return await additiveServices.DeleteAdditivel(request.AdditiveId,request.userName);
        }
    }
}
